package com.guldan.auth.web.controller;

import com.guldan.core.dubbo.client.ResponseDTO;
import com.guldan.core.response.ResponseJson;
import com.guldan.jaina.dto.feedback.FeedbackDTO;
import com.guldan.jaina.provider.IFeedbackProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Silas.
 * Date: 2017/2/23
 * Time: 11:07
 */
@Controller
@RequestMapping("/feedback")
public class FeedbackController {

    @Autowired
    private IFeedbackProvider iFeedbackProvider;
    //新增/保存单个反馈信息
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseJson
    public
    @ResponseBody
    FeedbackDTO save(@RequestBody FeedbackDTO dto) throws Exception {
        ResponseDTO<FeedbackDTO> response = iFeedbackProvider.save(dto);
        if (response.isSuccess())
            return response.getData();
        else {
            throw response.getException();
        }
    }
}
